import 'package:distribution_mall_flutter/generated/json/base/json_convert_content.dart';
import 'package:distribution_mall_flutter/pages/address/address_search/domain/address_search_entity.dart';

AddressSearchBody $AddressSearchBodyFromJson(Map<String, dynamic> json) {
  final AddressSearchBody addressSearchBody = AddressSearchBody();
  final AddressSearchBodyAddress? firstAddress = jsonConvert.convert<
      AddressSearchBodyAddress>(json['firstAddress']);
  if (firstAddress != null) {
    addressSearchBody.firstAddress = firstAddress;
  }
  final AddressSearchBodyAddress? secondAddress = jsonConvert.convert<
      AddressSearchBodyAddress>(json['secondAddress']);
  if (secondAddress != null) {
    addressSearchBody.secondAddress = secondAddress;
  }
  final AddressSearchBodyAddress? thirdAddress = jsonConvert.convert<
      AddressSearchBodyAddress>(json['thirdAddress']);
  if (thirdAddress != null) {
    addressSearchBody.thirdAddress = thirdAddress;
  }
  final AddressSearchBodyAddress? fourthAddress = jsonConvert.convert<
      AddressSearchBodyAddress>(json['fourthAddress']);
  if (fourthAddress != null) {
    addressSearchBody.fourthAddress = fourthAddress;
  }
  return addressSearchBody;
}

Map<String, dynamic> $AddressSearchBodyToJson(AddressSearchBody entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['firstAddress'] = entity.firstAddress?.toJson();
  data['secondAddress'] = entity.secondAddress?.toJson();
  data['thirdAddress'] = entity.thirdAddress?.toJson();
  data['fourthAddress'] = entity.fourthAddress?.toJson();
  return data;
}

extension AddressSearchBodyExtension on AddressSearchBody {
  AddressSearchBody copyWith({
    AddressSearchBodyAddress? firstAddress,
    AddressSearchBodyAddress? secondAddress,
    AddressSearchBodyAddress? thirdAddress,
    AddressSearchBodyAddress? fourthAddress,
  }) {
    return AddressSearchBody()
      ..firstAddress = firstAddress ?? this.firstAddress
      ..secondAddress = secondAddress ?? this.secondAddress
      ..thirdAddress = thirdAddress ?? this.thirdAddress
      ..fourthAddress = fourthAddress ?? this.fourthAddress;
  }
}

AddressSearchBodyAddress $AddressSearchBodyAddressFromJson(
    Map<String, dynamic> json) {
  final AddressSearchBodyAddress addressSearchBodyAddress = AddressSearchBodyAddress();
  final String? code = jsonConvert.convert<String>(json['code']);
  if (code != null) {
    addressSearchBodyAddress.code = code;
  }
  final String? virtualPostcode = jsonConvert.convert<String>(
      json['virtualPostcode']);
  if (virtualPostcode != null) {
    addressSearchBodyAddress.virtualPostcode = virtualPostcode;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    addressSearchBodyAddress.name = name;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    addressSearchBodyAddress.type = type;
  }
  final String? postcode = jsonConvert.convert<String>(json['postcode']);
  if (postcode != null) {
    addressSearchBodyAddress.postcode = postcode;
  }
  final bool? leafNode = jsonConvert.convert<bool>(json['leafNode']);
  if (leafNode != null) {
    addressSearchBodyAddress.leafNode = leafNode;
  }
  return addressSearchBodyAddress;
}

Map<String, dynamic> $AddressSearchBodyAddressToJson(
    AddressSearchBodyAddress entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['virtualPostcode'] = entity.virtualPostcode;
  data['name'] = entity.name;
  data['type'] = entity.type;
  data['postcode'] = entity.postcode;
  data['leafNode'] = entity.leafNode;
  return data;
}

extension AddressSearchBodyAddressExtension on AddressSearchBodyAddress {
  AddressSearchBodyAddress copyWith({
    String? code,
    String? virtualPostcode,
    String? name,
    String? type,
    String? postcode,
    bool? leafNode,
  }) {
    return AddressSearchBodyAddress()
      ..code = code ?? this.code
      ..virtualPostcode = virtualPostcode ?? this.virtualPostcode
      ..name = name ?? this.name
      ..type = type ?? this.type
      ..postcode = postcode ?? this.postcode
      ..leafNode = leafNode ?? this.leafNode;
  }
}